


import 'package:ai_desktop_eidtor/common/y_button.dart';
import 'package:ai_desktop_eidtor/common/y_text.dart';
import 'package:ai_desktop_eidtor/util/string_util.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class YAlert {
  static show(String content,{Function()? okBlock}){
    Get.dialog(NormalAlertPage(content,okBlock: okBlock,));
  }
}

class NormalAlertPage extends StatelessWidget{
  final String content;
  final Function()? okBlock;
  NormalAlertPage(this.content,{this.okBlock});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        width: 300,
        padding: EdgeInsets.only(left: 16,right: 16),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(10),
          color: Colors.white,
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            hSpace(16),
            YText(text: '温馨提示',decorationConfig: TextDecorationConfig()),
            hSpace(10),
            YText(text: content,maxLines: 10,decorationConfig: TextDecorationConfig()),
            hSpace(20),
            Row(
              children: [
                Expanded(child: YButton(text: '取消', onPressed: (){
                  Get.back();
                },backgroundColor: Colors.grey,)),
                wSpace(10),
                Expanded(child: YButton(text: '确定', onPressed: (){
                  if(okBlock != null){
                    okBlock!();
                  }
                  Get.back();
                },backgroundColor: Colors.blue,)),
              ],
            ),
            hSpace(16),
          ],
        ),
      ),
    );
  }
}